using System;
using System.Runtime.InteropServices;

namespace KodeIT.Web.Hosting
{
    /// <summary>
    /// This interface contains the COM visible methods used by the native ISAPI Filter to interact
    /// with the managed instance.
    /// </summary>
    [ComVisible(true)]
    public interface IProxyInstance
    {
        /// <summary>
        /// This method is used by the native ISAPI Filter to enumerate the native notifications the
        /// ISAPI Filter should register, in order to be notified by IIS.
        /// </summary>
        /// <returns>The combination of all events the native ISAPI Filter should register with IIS.</returns>
        FilterEvent Register();

        /// <summary>
        /// This method is used by the native ISAPI Filter to create an instance of the class responsible 
        /// to hold the custom properties associated with the current TCP session.
        /// </summary>
        /// <returns>An instance of the session instance.</returns>
        IProxySession CreateSession();

        FilterStatus OnRawData(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType, int rawLength);
        FilterStatus OnPreProcHeaders(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType);
        FilterStatus OnUrlMap(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType, int urlLength, int pathLength);
        FilterStatus OnAuthentication(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType);
        FilterStatus OnAccessDenied(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType, int urlLength, int pathLength, AccessDeniedReason reason);
        FilterStatus OnAuthComplete(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType, IntPtr token);
        FilterStatus OnSendResponse(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType, int httpStatus);
        FilterStatus OnLog(IProxySession session, IntPtr contextPtr, IntPtr eventPtr, FilterEvent eventType, int clientHostNameLength, int clientUserNameLength, int serverNameLength, int operationLength, int targetLength, int parametersLength, int httpStatus, int win32Status, int bytesSent, int bytesRecvd, int msTimeForProcessing);
        FilterStatus OnEndRequest(IProxySession session, IntPtr contextPtr, FilterEvent eventType);
        void Shutdown();
    }
}
